#undef main
#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif
#ifdef __APPLE__
#include <SDL/SDL.h>
#else
#include <SDL/SDL.h>
#endif
#include "global.h"
#include "gamemath.h"
#include <iostream>

class player
{
    public:
	boundingbox collisionmodel;
    int x, y,w,h, dir, state, health;
	polarcoord guntop, gunbottom;
	int gunoffsetangle, gunoffsetlength;
    double xv, yv;
	float xcounter, ycounter;
	bool movingup,movingdown,movingleft,movingright;

    int rotateplayer(int dir)
    {
     int x = dir;
     return x;
    }
    void moveLeft(int s)
    {
		movingleft=true;
		movingright=false;
    xv = -s;
    x+=xv;
		collisionmodel.x = x+((w/2)/2);
		collisionmodel.y = y+((h/2)/2);
    }
    void moveRight(int s)
    {
		movingright=true;
		movingleft=false;
    xv = s;
    x+=xv;
		collisionmodel.x = x+((w/2)/2);
		collisionmodel.y = y+((h/2)/2);
    }
    void moveUp(int s)
    {
		movingup=true;
		movingdown=false;
    yv = -s;
    y+=yv;
		collisionmodel.x = x+((w/2)/2);
		collisionmodel.y = y+((h/2)/2);
    }
    void moveDown(int s)
    {
		movingup=false;
		movingdown=true;
    yv = s;
    y+=yv;
		collisionmodel.x = x+((w/2)/2);
		collisionmodel.y = y+((h/2)/2);
    }
    void stopMoving()
    {
        xv =0;
        yv =0;
    }
	float getguntopx(double angle)
	{
		return gamemath::relativepolarx(angle,guntop.theta,guntop.radius)+x+(w/2);
	}
	float getguntopy(double angle)
	{
		return gamemath::relativepolary(angle,guntop.theta,guntop.radius)+y+(h/2);
	}
	float getgunbottomx(float angle)
	{
		return gamemath::relativepolarx(angle,gunbottom.theta,gunbottom.radius)+x+(w/2);
	}
	float getgunbottomy(float angle)
	{
		return gamemath::relativepolary(angle,gunbottom.theta,gunbottom.radius)+y+(h/2);
	}
    void init()
    {
		xcounter=0;
		ycounter=0;
        x = 128;
        y = 128;
        w=64;
		h=64;
		collisionmodel.x = x+((w/2)/2);
		collisionmodel.y = y+((h/2)/2);
		collisionmodel.w = (w/2);
		collisionmodel.h = (h/2);
    }

};
